<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  
</head>
<body style="height: 3000px;">
  <div id="app">
    <home></home>
  </div>
  <script src="./vue.js"></script>
  <script>
    // 创建一个子组件对象
    const Child = {
      template: `
        <div> 
          我是子组件
          {{ title}}
          {{ subTitle }}
          <ul>
            <li v-for="item in arr" :key="item">
              {{item}}  
            </li>  
          </ul>
        </div>
      `,
      // props 验证
      props:{
        title: Number,
        subTitle: {
          type: String,
          required: true
        },
        arr: {
          type:Array,
          default: ()=> [1,2,3]
        }
      },
      data(){
        return {
        
        }
      }
    }
    // 全局组件
    const Home =  {
      template: `
        <div> 
          我是home页，父组件
          <hr>
          <child :title="2" subTitle="111"></child>
        </div>
      `,
      data(){
        return {
          msg:33,
          
        }
      },
      components:{
        Child
      }
    }
    Vue.component('Home', Home)
    const vm = new Vue({
      el: '#app'
      
    })
  </script>
</body>
</html>